Page({
  /**
   * 页面的初始数据
   */
  data: {
    current:1,
    codeText:'获取验证码',
    counting:false,
    Phone:'',
    code:'',
    Password:''
  },
  //获取验证码 
 getCode(){
    var that = this;
    // console.log(this.data.Phone);
    // console.log( that.data.LoginPhone);
    if (!that.data.counting) {
      //获取验证码
      wx.request({
        url: 'https://api.gowow.cn/user/send/verificationCode',
        data: {
          "phonenumber": that.data.Phone
        },
        method:'POST',
        success (res) {
          console.log(res);
          wx.showToast({
            title: res.data.msg,
            icon: 'none'
            })
        }
      }) 
      //开始倒计时60秒
      that.countDown(that, 60);
    } 
 },
 //提交修改密码
 sumbitClick(){
  wx.request({
    url: 'https://api.gowow.cn/user/password/change',
    data: {
      "phonenumber": this.data.Phone,
      "password": this.data.Password,
      "code": this.data.code
    },
    method:'POST',
    success (res) {
      console.log(res);
      if (res.data.code == 0) {
        wx.navigateBack({
          delta:1
       })
      }
      wx.showToast({
        title: res.data.msg,
        icon: 'none'
      })
    }
  })
 },
 //监听手机号输入框的值
 inputPhone(event) {
  this.setData({
    Phone: event.detail.value || ''
  });
  // console.log(this.data.Phone);
 },
 //监听验证码输入框的值
 inputcode(event) {
  this.setData({
    code: event.detail.value || ''
  });
 },
 //监听密码输入框的值
 inputPassword(event) {
  this.setData({
    Password: event.detail.value || ''
  });
  // console.log(this.data.Password);
 },
  //倒计时60秒
  countDown(that,count){
    if (count == 0) {
      that.setData({
        codeText: '获取验证码',
        counting:false
      })
      return;
    }
    that.setData({
      counting:true,
      codeText: count + '秒后重新获取',
    })
    setTimeout(function(){
      count--;
      that.countDown(that, count);
    }, 1000);
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})
